package com.mySampleApplication.client.History;

import com.mySampleApplication.client.CodeRuleAtter.CodeRuleAtterLayout;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VLayout;


/**
 * 用法
 *      // 创建按钮和事件处理
 *      Button addButton = new Button("Add");
 *      addButton.setShowRollOver(true);
 *      addButton.setShowDown(true);
 *      addButton.addClickHandler(event -> showAddDialog(listGrid));
 *     private static void showAddDialog(ListGrid listGrid) {
 *       Window dialog=SShowWindow.getShowWindow();
 *       dialog.show();
 *     }
 */
public class HistoryWindow {
    public static Window getShowWindow(int width, int height, String title,final ListGridRecord record){
        final Window winModal = new Window();
        //winModal.setAutoSize(true);
        winModal.setWidth(width);
        winModal.setHeight(height);
        winModal.setTitle(title);
        winModal.setShowMinimizeButton(false);
        winModal.setIsModal(true);
        winModal.setShowModalMask(true);
        winModal.setCanDragReposition(true);
        winModal.setCanDragResize(true);
        winModal.centerInPage();
        winModal.addCloseClickHandler(new CloseClickHandler() {
            public void onCloseClick(CloseClickEvent event) {
                winModal.destroy();
            }
        });
        HStack layoutTopRow = new HStack(10);
        layoutTopRow.setHeight(50);
        VLayout layout = new CodeRuleLayout(record);
        layout.setWidth100();
        layout.setHeight100();

        winModal.addItem(layout);
        return winModal;
    }

}
